﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace XNA_Game_Framework
{
	public class Pointer : Control
	{
		Theme.Pointer theme;
		int height;

		public override Vector2 Size
		{
			get {return new Vector2(theme.pointerTop.Width, height); }
		}

		public Pointer(object parent, string name, Vector2 position, int height, Theme.Pointer theme)
			: base(name, parent, position)
		{
			this.theme = theme;

			this.height = height;
		}

		internal override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
		{
			if(hasFocus == false || (int)(Screen.gameTime.TotalGameTime.Milliseconds/400)%2 == 1){
				Vector2 position = WindowPosition;
				spriteBatch.Draw(theme.pointerTop, position, Color.White);

				int bodyHeight = height - theme.pointerTop.Height - theme.pointerBottom.Height;
				int bodyTextureHeight = (int)theme.pointerBody.Height;

				position.Y += theme.pointerTop.Height;
				for (int i = 0; i < bodyHeight; i+=bodyTextureHeight)
				{
					spriteBatch.Draw(theme.pointerBody, position, Color.White);
					position.Y += theme.pointerBody.Height;
				}
				spriteBatch.Draw(theme.pointerBottom, position, Color.White);
			}
		}
	}
}
